gender("keith", method="ssa", certainty=TRUE)$proportion_male
gender("kim", method="ssa", certainty=TRUE)$proportion_male
gender("Ted", method="ssa", certainty=TRUE)$proportion_male
gender("Carole", method="ssa", certainty=TRUE)$proportion_male
gender("Armstrong", method="ssa", certainty=TRUE)$proportion_male
gender("Christine", method="ssa", certainty=TRUE)$proportion_male
gender("Linda", method="ssa", certainty=TRUE)$proportion_male
gender("Wayne", method="ssa", certainty=TRUE)$proportion_male
gender("Vern", method="ssa", certainty=TRUE)$proportion_male
gender("Butch", method="ssa", certainty=TRUE)$proportion_male
gender("Hilary", method="ssa", certainty=TRUE)$proportion_male
gender("Dean", method="ssa", certainty=TRUE)$proportion_male
gender("Linda", method="ssa", certainty=TRUE)$proportion_male
gender("aNN", method="ssa", certainty=TRUE)$proportion_male
gender("Lorraine", method="ssa", certainty=TRUE)$proportion_male
gender("Kathy", method="ssa", certainty=TRUE)$proportion_male
gender("Chester", method="ssa", certainty=TRUE)$proportion_male
gender("Vikki", method="ssa", certainty=TRUE)$proportion_male
gender("Teresa", method="ssa", certainty=TRUE)$proportion_male
gender("Angel", method="ssa", certainty=TRUE)$proportion_male
gender("Kent", method="ssa", certainty=TRUE)$proportion_male
gender("America", method="ssa", certainty=TRUE)$proportion_male
gender("Anne", method="ssa", certainty=TRUE)$proportion_male
gender("Marnie", method="ssa", certainty=TRUE)$proportion_male
gender("Magdalene", method="ssa", certainty=TRUE)$proportion_male
gender("sHANNON", method="ssa", certainty=TRUE)$proportion_male
gender("MA", method="ssa", certainty=TRUE)$proportion_male
gender("MD", method="ssa", certainty=TRUE)$proportion_male
gender("cokry", method="ssa", certainty=TRUE)$proportion_male
gender("corky", method="ssa", certainty=TRUE)$proportion_male
gender("marcelo", method="ssa", certainty=TRUE)$proportion_male
gender("marilyn", method="ssa", certainty=TRUE)$proportion_male
gender("marleen", method="ssa", certainty=TRUE)$proportion_male
gender("michael", method="ssa", certainty=TRUE)$proportion_male
gender("mick", method="ssa", certainty=TRUE)$proportion_male
gender("ace", method="ssa", certainty=TRUE)$proportion_male
gender("nj", method="ssa", certainty=TRUE)$proportion_male
gender("michael", method="ssa", certainty=TRUE)$proportion_male
gender("joseph", method="ssa", certainty=TRUE)$proportion_male
gender("elizabeth", method="ssa", certainty=TRUE)$proportion_male
gender("tony", method="ssa", certainty=TRUE)$proportion_male
gender("pj", method="ssa", certainty=TRUE)$proportion_male
gender("paul", method="ssa", certainty=TRUE)$proportion_male
gender("dean", method="ssa", certainty=TRUE)$proportion_male
gender("philip", method="ssa", certainty=TRUE)$proportion_male
gender("michael", method="ssa", certainty=TRUE)$proportion_male
gender("jan", method="ssa", certainty=TRUE)$proportion_male
gender("wayne", method="ssa", certainty=TRUE)$proportion_male
gender("marty", method="ssa", certainty=TRUE)$proportion_male
gender("chip", method="ssa", certainty=TRUE)$proportion_male
gender("scott", method="ssa", certainty=TRUE)$proportion_male
gender("steven", method="ssa", certainty=TRUE)$proportion_male
gender("steve", method="ssa", certainty=TRUE)$proportion_male
gender("rg", method="ssa", certainty=TRUE)$proportion_male
gender("bob", method="ssa", certainty=TRUE)$proportion_male
gender("sally", method="ssa", certainty=TRUE)$proportion_male
gender("mike", method="ssa", certainty=TRUE)$proportion_male
gender("paul", method="ssa", certainty=TRUE)$proportion_male
gender("phoebe", method="ssa", certainty=TRUE)$proportion_male
gender("burton", method="ssa", certainty=TRUE)$proportion_male
gender("scott", method="ssa", certainty=TRUE)$proportion_male
gender("gina", method="ssa", certainty=TRUE)$proportion_male
gender("reagan", method="ssa", certainty=TRUE)$proportion_male
gender("raquel", method="ssa", certainty=TRUE)$proportion_male
gender("ritta", method="ssa", certainty=TRUE)$proportion_male
gender("ruth", method="ssa", certainty=TRUE)$proportion_male
gender("casey", method="ssa", certainty=TRUE)$proportion_male
gender("sean", method="ssa", certainty=TRUE)$proportion_male
gender("martinez", method="ssa", certainty=TRUE)$proportion_male
gender("camie", method="ssa", certainty=TRUE)$proportion_male
gender("sienna", method="ssa", certainty=TRUE)$proportion_male
gender("monique", method="ssa", certainty=TRUE)$proportion_male
gender("cruz", method="ssa", certainty=TRUE)$proportion_male
gender("robert", method="ssa", certainty=TRUE)$proportion_male
gender("sharron", method="ssa", certainty=TRUE)$proportion_male
gender("susan", method="ssa", certainty=TRUE)$proportion_male
gender("cynthia", method="ssa", certainty=TRUE)$proportion_male
gender("anne", method="ssa", certainty=TRUE)$proportion_male
gender("tj", method="ssa", certainty=TRUE)$proportion_male
gender("tm", method="ssa", certainty=TRUE)$proportion_male
gender("rick", method="ssa", certainty=TRUE)$proportion_male
gender("timothy", method="ssa", certainty=TRUE)$proportion_male
gender("joe", method="ssa", certainty=TRUE)$proportion_male
gender("jinny", method="ssa", certainty=TRUE)$proportion_male
gender("wayne", method="ssa", certainty=TRUE)$proportion_male
gender("bill", method="ssa", certainty=TRUE)$proportion_male
gender("anne", method="ssa", certainty=TRUE)$proportion_male
gender("ann", method="ssa", certainty=TRUE)$proportion_male
gender("beatrice", method="ssa", certainty=TRUE)$proportion_male
gender("barry", method="ssa", certainty=TRUE)$proportion_male
gender("raymond", method="ssa", certainty=TRUE)$proportion_male
gender("bill", method="ssa", certainty=TRUE)$proportion_male
gender("mack", method="ssa", certainty=TRUE)$proportion_male
gender("lee", method="ssa", certainty=TRUE)$proportion_male
gender("scott", method="ssa", certainty=TRUE)$proportion_male
gender("clark", method="ssa", certainty=TRUE)$proportion_male
gender("allan", method="ssa", certainty=TRUE)$proportion_male
gender("charles", method="ssa", certainty=TRUE)$proportion_male
gender("patrick", method="ssa", certainty=TRUE)$proportion_male
gender("tony", method="ssa", certainty=TRUE)$proportion_male
gender("flores", method="ssa", certainty=TRUE)$proportion_male
gender("yvonne", method="ssa", certainty=TRUE)$proportion_male
require(sbw)
install.packages("sbw")
R.Version()
install.packages("installr")
installr::updateR()
library(installr)
setInternet2(TRUE)
installr::updateR()
library(sbw)
sbw = function(data_frame, t_ind, bal_covs, bal_tols, bal_tols_sd=TRUE, target="treated", l_norm="l_2", w_min=0, normalize=1, solver, display=0, max_iter=100000,  rel_tol=1e-4, abs_tol=1e-4, gap_stop=TRUE, adaptive_rho=TRUE) {
if (target=="treated") {
data_frame = data_frame[order(data_frame[, t_ind], decreasing=TRUE), ]
t_ind = data_frame[, t_ind]
bal_covs = data_frame[, bal_covs]
if (length(bal_tols)>1) {
if (bal_tols_sd==TRUE) {
bal_tols = round(apply(bal_covs, 2, sd)*bal_tols, 9)
}
}
if (length(bal_tols)==1) {
if (bal_tols_sd==TRUE) {
bal_tols = round(apply(bal_covs, 2, sd)*bal_tols, 9)
}
if (bal_tols_sd==FALSE) {
bal_tols = rep(bal_tols, length(bal_tols))
}
}
bal_covs = as.matrix(bal_covs)
}
if (target=="controls") {
data_frame = data_frame[order(data_frame[, t_ind], decreasing=FALSE), ]
t_ind = 1-data_frame[, t_ind]
bal_covs = data_frame[, bal_covs]
if (length(bal_tols)>1) {
if (bal_tols_sd==TRUE) {
bal_tols = round(apply(bal_covs, 2, sd)*bal_tols, 9)
}
}
if (length(bal_tols)==1) {
if (bal_tols_sd==TRUE) {
bal_tols = round(apply(bal_covs, 2, sd)*bal_tols, 9)
}
if (bal_tols_sd==FALSE) {
bal_tols = rep(bal_tols, length(bal_tols))
}
}
bal_covs = as.matrix(bal_covs)
}
if (target=="all") {
data_frame = data_frame[order(data_frame[, t_ind], decreasing=TRUE), ]
t_ind = data_frame[, t_ind]
bal_covs = data_frame[, bal_covs]
if (length(bal_tols)>1) {
if (bal_tols_sd==TRUE) {
bal_tols = round(apply(bal_covs, 2, sd)*bal_tols, 9)
}
}
if (length(bal_tols)==1) {
if (bal_tols_sd==TRUE) {
bal_tols = round(apply(bal_covs, 2, sd)*bal_tols, 9)
}
if (bal_tols_sd==FALSE) {
bal_tols = rep(bal_tols, length(bal_tols))
}
}
bal_covs = as.matrix(rbind(bal_covs, bal_covs[t_ind==0, ]))
t_ind = c(rep(1, length(t_ind)), rep(0, sum(1-t_ind)))
}
n_t = sum(t_ind)
n_c = length(t_ind)-n_t
n_bal_covs = ncol(bal_covs)
if (l_norm == "l_1") {
cvec = c(rep(0, n_c), rep(1, n_c))
}
if (l_norm == "l_inf") {
cvec = c(rep(0, n_c), 1)
}
if (l_norm == "l_2") {
cvec = rep(0, n_c)
Qmat = diag(n_c)-1/n_c*(matrix(1, nrow=n_c, ncol=n_c))
}
row_ind_cur = 0
if (l_norm == "l_1") {
row_ind_l_norm = sort(rep(1:(n_c*2), n_c+1))+row_ind_cur
col_ind_l_norm = matrix(rep(1:n_c, n_c*2), nrow = n_c)
col_ind_l_norm = rbind(col_ind_l_norm, sort(rep((1:n_c)+n_c, 2)))
col_ind_l_norm = as.vector(col_ind_l_norm)
vals_l_1 = rep(c(rep(-1/n_c, n_c), -1, rep(1/n_c, n_c), -1), n_c)
aux_ind = ((sort(rep(1:n_c, 2))-1)*(n_c+1))+sort(rep((0:(n_c-1)), 2))+c(1, 1, rep(0, (n_c*2)-2))
vals_l_1[aux_ind] = rep(c(1, -1), n_c)+vals_l_1[aux_ind]
row_ind_cur = max(row_ind_l_norm)
}
if (l_norm == "l_inf") {
row_ind_l_norm = sort(rep(1:(n_c*2), n_c+1))+row_ind_cur
col_ind_l_norm = matrix(rep(1:n_c, n_c*2), nrow = n_c)
col_ind_l_norm = rbind(col_ind_l_norm, rep(n_c+1, n_c*2))
col_ind_l_norm = as.vector(col_ind_l_norm)
vals_l_1 = rep(c(rep(-1/n_c, n_c), -1, rep(1/n_c, n_c), -1), n_c)
aux_ind = ((sort(rep(1:n_c, 2))-1)*(n_c+1))+sort(rep((0:(n_c-1)), 2))+c(1, 1, rep(0, (n_c*2)-2))
vals_l_1[aux_ind] = rep(c(1, -1), n_c)+vals_l_1[aux_ind]
row_ind_cur = max(row_ind_l_norm)
}
bal_covs_c = bal_covs[t_ind==0, ]
row_ind_mom = sort(rep(1:(n_bal_covs*2), n_c))+row_ind_cur
col_ind_mom = rep(1:n_c, n_bal_covs*2)
vals_mom = cbind(bal_covs_c, -bal_covs_c)[, sort(rep(1:n_bal_covs, 2))+rep(c(0, n_bal_covs), n_bal_covs)]
row_ind_cur = max(row_ind_mom)+1
if (normalize == 1) {
row_ind_normalize = rep(row_ind_cur, n_c)
col_ind_normalize = 1:n_c
vals_normalize = rep(1, n_c)
row_ind_cur = max(row_ind_normalize)+1
}
if (l_norm == "l_1" | l_norm == "l_inf") {
row_ind = c(row_ind_l_norm, row_ind_mom)
col_ind = c(col_ind_l_norm, col_ind_mom)
vals = c(vals_l_1, vals_mom)
if (normalize == 1) {
row_ind = c(row_ind_l_norm, row_ind_mom, row_ind_normalize)
col_ind = c(col_ind_l_norm, col_ind_mom, col_ind_normalize)
vals = c(vals_l_1, vals_mom, vals_normalize)
}
}
if (l_norm == "l_2") {
row_ind = c(row_ind_mom)
col_ind = c(col_ind_mom)
vals = c(vals_mom)
if (normalize == 1) {
row_ind = c(row_ind_mom, row_ind_normalize)
col_ind = c(col_ind_mom, col_ind_normalize)
vals = c(vals_mom, vals_normalize)
}
}
aux = cbind(row_ind, col_ind, vals)[order(col_ind), ]
Amat = simple_triplet_matrix(i = aux[, 1], j = aux[, 2], v = aux[, 3])
if (l_norm == "l_1" | l_norm == "l_inf") {
bvec = rep(0, n_c*2)
bal_covs_t_mean = apply(bal_covs[t_ind==1, ], 2, mean)
bvec_mom = c(bal_covs_t_mean+bal_tols, -bal_covs_t_mean+bal_tols)[sort(rep(1:n_bal_covs, 2))+rep(c(0, n_bal_covs), n_bal_covs)]
bvec = c(bvec, bvec_mom)
if (normalize == 1) {
bvec = c(bvec, 1)
}
}
if (l_norm == "l_2") {
bal_covs_t_mean = apply(bal_covs[t_ind==1, ], 2, mean)
bvec_mom = c(bal_covs_t_mean+bal_tols, -bal_covs_t_mean+bal_tols)[sort(rep(1:n_bal_covs, 2))+rep(c(0, n_bal_covs), n_bal_covs)]
bvec = bvec_mom
if (normalize == 1) {
bvec = c(bvec, 1)
}
}
if (l_norm == "l_1") {
lb = rep(w_min, n_c)
lb = c(lb, rep(0, n_c))
}
if (l_norm == "l_inf") {
lb = rep(w_min, n_c)
lb = c(lb, 0)
}
if (l_norm == "l_2") {
lb = rep(w_min, n_c)
}
if (l_norm == "l_1") {
ub = rep(Inf, n_c*2)
}
if (l_norm == "l_inf") {
ub = rep(Inf, 1+n_c)
}
if (l_norm == "l_2") {
ub = rep(Inf, n_c)
}
if (l_norm == "l_1") {
sense = rep("L", n_c*2)
sense = c(sense, rep("L", n_bal_covs*2))
if (normalize == 1) {
sense = c(sense, "E")
}
}
if (l_norm == "l_inf") {
sense = rep("L", n_c*2)
sense = c(sense, rep("L", n_bal_covs*2))
if (normalize == 1) {
sense = c(sense, "E")
}
}
if (l_norm == "l_2") {
sense = rep("L", n_bal_covs*2)
if (normalize == 1) {
sense = c(rep("L", n_bal_covs*2), "E")
}
}
if (l_norm == "l_1") {
var_type = rep("C", n_c*2)
}
if (l_norm == "l_inf") {
var_type = rep("C", 1+n_c)
}
if (l_norm == "l_2") {
var_type = rep("C", n_c)
}
if (solver == "cplex") {
cat(format("  CPLEX optimizer is open..."), "\n")
cat(format("  Finding the optimal weights..."), "\n")
ptm = proc.time()
if (l_norm == "l_1" | l_norm == "l_inf") {
out = Rcplex(cvec, Amat, bvec, lb = lb, ub = ub, sense = sense, vtype = var_type, n = 1, control = list(trace = display))
}
if (l_norm == "l_2") {
out = Rcplex(cvec, Amat, bvec, 2*Qmat, lb = lb, ub = ub, sense = sense, vtype = var_type, n = 1, control = list(trace = display))
}
time = (proc.time()-ptm)[3]
weights = (out$xopt)[1:n_c]
cat(format("  Optimal weights found."), "\n")
data_frame_weights = data_frame
if (target=="treated") {
data_frame_weights$weights = c(rep(0, n_t), weights)
}
if (target=="controls") {
data_frame_weights$weights = c(rep(0, n_t), weights)
data_frame_weights = data_frame_weights[order(data_frame_weights$t_ind, decreasing=TRUE), ]
}
if (target=="all") {
data_frame_weights$weights = c(rep(0, nrow(data_frame_weights)-length(weights)), weights)
}
obj_total = out$obj
status = out$status
dual_vars = out$extra$lambda[-length(out$extra$lambda)]
return(list(obj_total = obj_total, time = time, status = status, data_frame_weights = data_frame_weights, dual_vars = dual_vars))
}
if (solver == "gurobi") {
model = list()
model$modelsense = 'min'
model$obj = cvec
model$A = Amat
model$sense = rep(NA, length(sense))
model$sense[sense=="E"] = '='
model$sense[sense=="L"] = '<='
model$sense[sense=="G"] = '>='
model$rhs = bvec
model$vtype = var_type
model$ub = ub
params = list(OutputFlag = display)
cat(format("  Gurobi optimizer is open..."), "\n")
cat(format("  Finding the optimal weights..."), "\n")
ptm = proc.time()
if (l_norm == "l_1" | l_norm == "l_inf") {
out = gurobi(model, params)
}
if (l_norm == "l_2") {
model$Q = Qmat
out = gurobi(model, params)
}
time = (proc.time()-ptm)[3]
weights = (out$x)[1:n_c]
cat(format("  Optimal weights found."), "\n")
data_frame_weights = data_frame
if (target=="treated") {
data_frame_weights$weights = c(rep(0, n_t), weights)
}
if (target=="controls") {
data_frame_weights$weights = c(rep(0, n_t), weights)
data_frame_weights = data_frame_weights[order(data_frame_weights$t_ind, decreasing=TRUE), ]
}
if (target=="all") {
data_frame_weights$weights = c(rep(0, nrow(data_frame_weights)-length(weights)), weights)
}
obj_total = out$obj
status = out$status
dual_vars = out$pi[-length(out$pi)]
return(list(obj_total = obj_total, time = time, status = status, data_frame_weights = data_frame_weights, dual_vars = dual_vars))
}
if (solver == "quadprog") {
cat(format("  quadprog optimizer is open..."), "\n")
cat(format("  Finding the optimal weights..."), "\n")
ptm = proc.time()
if (l_norm == "l_1" | l_norm == "l_inf") {
stop("Minimizing the l_1 or l_inf norm is not a valid option with quadprog; use either cplex or gurobi")
}
if (l_norm == "l_2") {
Dmat = matrix(0,nrow(Qmat),nrow(Qmat))
diag(Dmat) = 2
dvec = rep(0, length(cvec))
Amat = as.matrix(Amat)
## Intervert the first line with the last line of
## Amat and bvec
###bvec
tmp=bvec[1]
bvec[1]=bvec[length(bvec)]
bvec[length(bvec)]=tmp
###Amat
tmp = Amat[1,]
Amat[1,] = Amat[nrow(Amat),]
Amat[nrow(Amat),] = tmp
##Adding the non-negativity constraints
###Amat
Amat2=matrix(0,nrow(Amat)+ncol(Amat),ncol(Amat))
Amat2[1:nrow(Amat),1:ncol(Amat)]=Amat
Amat2[(1+nrow(Amat)):(nrow(Amat)+ncol(Amat)),1:ncol(Amat)]=-1*diag(ncol(Amat))
###bvec
bvec2=rep(0,(length(bvec)+nrow(Qmat)))
bvec2[1:length(bvec)]=bvec
##Adapting the matrices to the quadprog
Amat4 = -t(Amat2)
bvec4 = -bvec2
##Solving the QP
out = solve.QP(Dmat, dvec, Amat4, bvec4, meq=1)
}
# cbind(t(Amat4)%*%out$solution, bvec4, t(Amat4)%*%out$solution>=bvec4)
# table(out$solution>=0)
time = (proc.time()-ptm)[3]
weights = (out$solution)[1:n_c]
cat(format("  Optimal weights found."), "\n")
data_frame_weights = data_frame
if (target=="treated") {
data_frame_weights$weights = c(rep(0, n_t), weights)
}
if (target=="controls") {
data_frame_weights$weights = c(rep(0, n_t), weights)
data_frame_weights = data_frame_weights[order(data_frame_weights$t_ind, decreasing=TRUE), ]
}
if (target=="all") {
data_frame_weights$weights = c(rep(0, nrow(data_frame_weights)-length(weights)), weights)
}
obj_total = out$value-1/n_c
status = NA
dual_vars = out$Lagrangian[-length(out$Lagrangian)]
return(list(obj_total = obj_total, time = time, status = status, data_frame_weights = data_frame_weights, dual_vars = dual_vars))
}
if (solver == "pogs") {
cat(format("  POGS optimizer is open..."), "\n")
cat(format("  Finding the optimal weights..."), "\n")
ptm = proc.time()
if (l_norm == "l_1" | l_norm == "l_inf") {
stop("Minimizing the l_1 or l_inf norm is not a valid option with pogs; use either cplex or gurobi")
}
if (l_norm == "l_2") {
if(normalize == 1){
nbL = nrow(Amat)-1
f = list(h = c(kIndLe0(nbL), kIndEq0(1)), b = bvec, a = 1, c = 1, d = 0, e = 0)
g = list(h = kIndGe0(), c=1,a=1,d=0,e=1)
Amat = as.matrix(Amat)
out = pogs(Amat, f, g,params=list(rel_tol = abs_tol, abs_tol = abs_tol, max_iter = max_iter, adaptive_rho = adaptive_rho, verbose = display, gap_stop = gap_stop))
}
else{
#stop("You can not")
Amat = as.matrix(Amat)
nbL = nrow(Amat)
nbC = ncol(Amat)
print("Amat")
#print(Amat)
Amat2 = matrix(0,(nbL+1),(nbC+1))
Amat2[1:nbL,1:nbC] = Amat
Amat2[(nbL+1),] = c(rep(1,nbC),-1)
#print("Amat2")
#print(Amat2)
f = list(h = c(kIndLe0(nbL), kIndEq0(1)), b = c(bvec,0), a = 1, c = 1, d = 0, e = 0)
g = list(h = kIndGe0(), c = 1, a = 1, d = 0, e = c(rep(2,nbC),-2/n_c))
Amat2 = as.matrix(Amat2)
out = pogs(Amat2, f, g,params=list(rel_tol = abs_tol, abs_tol = abs_tol, max_iter = max_iter, adaptive_rho = adaptive_rho, verbose = display, gap_stop = gap_stop))
}
}
time = (proc.time()-ptm)[3]
weights = (out$x)[1:n_c]
cat(format("  Optimal weights found."), "\n")
data_frame_weights = data_frame
if (target=="treated") {
data_frame_weights$weights = c(rep(0, n_t), weights)
}
if (target=="controls") {
data_frame_weights$weights = c(rep(0, n_t), weights)
data_frame_weights = data_frame_weights[order(data_frame_weights$t_ind, decreasing=TRUE), ]
}
if (target=="all") {
data_frame_weights$weights = c(rep(0, nrow(data_frame_weights)-length(weights)), weights)
}
obj_total = 2*out$optval-1/n_c
status = out$status
dual_vars = out$u
return(list(obj_total = obj_total, time = time, status = status, data_frame_weights = data_frame_weights, dual_vars = dual_vars))
}
}
sbw
set.seed(1)
library("HierarchicalEdgeBundles")
library("igraph")
library("ape")
# Create a graph and a tree
graph <- watts.strogatz.game(1, size = 9, nei = 2, p = 0.5)
V(graph)$name <- paste("Node", 1:9)
adj.mat <- get.adjacency(graph)
phylo <- as.phylo(hclust(as.dist(1-adj.mat)))
# Plot
plotHEB(graph, phylo, beta = 0.9, type = "fan")
devtools::install_github("AEBilgrau/HierarchicalEdgeBundles")
set.seed(1)
library("HierarchicalEdgeBundles")
library("igraph")
library("ape")
# Create a graph and a tree
graph <- watts.strogatz.game(1, size = 9, nei = 2, p = 0.5)
V(graph)$name <- paste("Node", 1:9)
adj.mat <- get.adjacency(graph)
phylo <- as.phylo(hclust(as.dist(1-adj.mat)))
# Plot
plotHEB(graph, phylo, beta = 0.9, type = "fan")
df <- read.csv("coords_spc.csv")
setwd("~/Dropbox (MIT)/Research/NYC421a/data/raw")
df <- read.csv("coords_spc.csv")
head(df)
